/* Preston Cowley  */

package fatboy.hypeerweb;

import junit.framework.Assert;
import org.junit.Test;

public class TestInsertionPoint {

	
	@Test
	public void findInsertionPointTest1()
	{		
		Node root = new Node(null, NodeType.LAST_NODE, new NodeAddress(0));	
		
		Node result = root.findInsertionPoint();
		
		Assert.assertEquals(root, result);
	}
	
	@Test
	
	public void findInsertionPointTest2()
	{		
		Node root = new Node(null, NodeType.INTERIOR_NODE, new NodeAddress(0));
		Node second = new Node(null, NodeType.LAST_NODE, new NodeAddress(1));	
		
		root.getNeighbors().add(second);
		second.getNeighbors().add(root);
		second.setFoldPointer(root);
		root.setFoldPointer(second);
		Node result1 = root.findInsertionPoint();
		second.setNodeState(NodeType.LAST_NODE); 
		Node result2 = second.findInsertionPoint();
		
		Assert.assertEquals(root, result1);
		Assert.assertEquals(root, result2);
	}
	
	@Test
	public void findInsertionPointTest3()
	{		
		Node root = new Node(null, NodeType.INTERIOR_NODE, new NodeAddress(0));
		Node second = new Node(null, NodeType.SURFACE_NODE, new NodeAddress(1));
		Node third = new Node(null, NodeType.EDGE_NODE, new NodeAddress(2));	
		
		root.getNeighbors().add(second);
		root.getNeighbors().add(third);
		second.getNeighbors().add(root);
		third.getNeighbors().add(root);
		second.getPointers().add(new EdgePointer(third));
		third.getPointers().add(new SurrogatePointer(second));
		third.setParent(root);
		Node result1 = root.findInsertionPoint();
		Node result2 = second.findInsertionPoint();
		Node result3 = third.findInsertionPoint();
		
		Assert.assertEquals(result1, root);
		Assert.assertEquals(result2, root);	
		Assert.assertEquals(result3, second);		
	}
	
	/*
	@Test
	public void findInsertionPointTest4()
	{		
		Node root = new Node(null, NodeType.INTERIOR_NODE, new NodeAddress(0));
		Node second = new Node(null, NodeType.INTERIOR_NODE, new NodeAddress(1));
		Node third = new Node(null, NodeType.INTERIOR_NODE, new NodeAddress(2));		
		Node fourth = new Node(null, NodeType.LAST_NODE, new NodeAddress(3));	
		
		//setup cube
		
		Node result1 = root.getNodeState().findInsertionPoint(root);
		Node result2 = second.getNodeState().findInsertionPoint(second);
		Node result3 = third.getNodeState().findInsertionPoint(third);
		Node result4 = fourth.getNodeState().findInsertionPoint(fourth);
		
		Assert.assertEquals(result1, root);
		Assert.assertEquals(result2, root);	
		Assert.assertEquals(result3, root);	
		Assert.assertEquals(result4, root);		
	}
	
	@Test
	public void findInsertionPointTest5()
	{		
		Node root = new Node(null, NodeType.SURFACE_NODE, new NodeAddress(0));
		Node second = new Node(null, NodeType.SURFACE_NODE, new NodeAddress(1));
		Node third = new Node(null, NodeType.SURFACE_NODE, new NodeAddress(2));		
		Node fourth = new Node(null, NodeType.SURFACE_NODE, new NodeAddress(3));		
		Node fifth = new Node(null, NodeType.EDGE_NODE, new NodeAddress(4));
		
		//setup cube
		
		Node result1 = root.getNodeState().findInsertionPoint(root);
		Node result2 = second.getNodeState().findInsertionPoint(second);
		Node result3 = third.getNodeState().findInsertionPoint(third);
		Node result4 = fourth.getNodeState().findInsertionPoint(fourth);
		Node result5 = fifth.getNodeState().findInsertionPoint(fifth);
		
		Assert.assertEquals(result1, second);
		Assert.assertEquals(result2, second);	
		Assert.assertEquals(result3, second);	
		Assert.assertEquals(result4, second);		
		Assert.assertEquals(result5, second);	
	}
	

	
	@Test
	public void findInsertionPointTest6()
	{		
		Node root = new Node(null, NodeType.SURFACE_NODE, new NodeAddress(0));
		Node second = new Node(null, NodeType.SURFACE_NODE, new NodeAddress(1));
		Node third = new Node(null, NodeType.SURFACE_NODE, new NodeAddress(2));		
		Node fourth = new Node(null, NodeType.SURFACE_NODE, new NodeAddress(3));		
		Node fifth = new Node(null, NodeType.EDGE_NODE, new NodeAddress(4));		
		Node sixth = new Node(null, NodeType.EDGE_NODE, new NodeAddress(5));	
		
		//setup cube
		
		Node result1 = root.getNodeState().findInsertionPoint(root);
		Node result2 = second.getNodeState().findInsertionPoint(second);
		Node result3 = third.getNodeState().findInsertionPoint(third);
		Node result4 = fourth.getNodeState().findInsertionPoint(fourth);
		Node result5 = fifth.getNodeState().findInsertionPoint(fifth);
		Node result6 = sixth.getNodeState().findInsertionPoint(sixth);
		
		Assert.assertEquals(result1, third);
		Assert.assertEquals(result2, third);	
		Assert.assertEquals(result3, third);	
		Assert.assertEquals(result4, third);		
		Assert.assertEquals(result5, third);		
		Assert.assertEquals(result6, third);	
	}*/
	
}
